<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>文档处理工具 - PDF去除彩色内容</title>
    <link href="https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    
    <!-- 预加载关键资源 -->
    <link rel="preload" href="/word" as="document">
    <link rel="prefetch" href="/word">
    
    <style>
        :root {
            --primary-color: #3498db;
            --primary-dark: #2980b9;
            --secondary-color: #2ecc71;
            --secondary-dark: #27ae60;
            --text-color: #333;
            --light-gray: #f5f5f5;
            --medium-gray: #e0e0e0;
            --dark-gray: #777;
            --white: #ffffff;
            --shadow: 0 4px 15px rgba(0,0,0,0.1);
            --border-radius: 8px;
            --transition: all 0.3s ease;
        }
        
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        
        body {
            font-family: 'Noto Sans SC', 'Microsoft YaHei', sans-serif;
            line-height: 1.5;
            color: var(--text-color);
            background-color: var(--light-gray);
            display: flex;
            flex-direction: column;
            min-height: 100vh;
            font-size: 0.95rem;
        }
        
        .container {
            max-width: 900px;
            width: 90%;
            margin: 40px auto;
            background-color: var(--white);
            padding: 40px;
            border-radius: var(--border-radius);
            box-shadow: var(--shadow);
            animation: fadeIn 0.8s ease;
        }
        
        @keyframes fadeIn {
            from {
                opacity: 0;
                transform: translateY(10px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }
        
        h1 {
            color: var(--primary-color);
            text-align: center;
            margin-bottom: 25px;
            font-weight: 700;
            font-size: 1.9rem;
            position: relative;
            padding-bottom: 12px;
        }
        
        h1::after {
            content: '';
            position: absolute;
            bottom: 0;
            left: 50%;
            transform: translateX(-50%);
            width: 100px;
            height: 4px;
            background: linear-gradient(to right, var(--primary-color), var(--secondary-color));
            border-radius: 2px;
        }
        
        /* 导航菜单样式 */
        .nav-menu {
            display: flex;
            justify-content: center;
            margin-bottom: 30px;
            background-color: var(--light-gray);
            border-radius: var(--border-radius);
            padding: 5px;
            box-shadow: 0 2px 5px rgba(0,0,0,0.1);
        }
        
        .nav-menu a {
            text-decoration: none;
            color: var(--text-color);
            padding: 10px 20px;
            border-radius: var(--border-radius);
            margin: 0 5px;
            transition: all 0.1s ease;
            font-weight: 500;
            position: relative;
            overflow: hidden;
        }
        
        .nav-menu a::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-color: var(--primary-color);
            border-radius: var(--border-radius);
            z-index: -1;
            transform: translateY(100%);
            transition: transform 0.1s ease;
        }
        
        .nav-menu a:hover {
            color: var(--white);
        }
        
        .nav-menu a:hover::before {
            transform: translateY(0);
        }
        
        .nav-menu a.active {
            background-color: var(--primary-color);
            color: white;
        }
        
        .nav-menu a i {
            margin-right: 8px;
        }
        
        .upload-form {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 25px;
            margin: 40px 0;
        }
        
        .file-input-container {
            position: relative;
            width: 100%;
            max-width: 500px;
        }
        
        .file-input-container input[type="file"] {
            position: absolute;
            top: 0;
            left: 0;
            opacity: 0;
            width: 100%;
            height: 100%;
            cursor: pointer;
            z-index: 2;
        }
        
        .file-input-label {
            display: flex;
            align-items: center;
            justify-content: center;
            height: 55px;
            background-color: var(--light-gray);
            border: 2px dashed var(--primary-color);
            border-radius: var(--border-radius);
            text-align: center;
            padding: 12px;
            transition: var(--transition);
            color: var(--text-color);
            font-weight: 500;
            font-size: 0.95rem;
        }
        
        .file-input-label i {
            margin-right: 8px;
            font-size: 1.3rem;
            color: var(--primary-color);
        }
        
        .file-input-label:hover {
            background-color: var(--medium-gray);
            transform: translateY(-2px);
            box-shadow: var(--shadow);
        }
        
        button {
            background: linear-gradient(to right, var(--secondary-color), var(--secondary-dark));
            color: white;
            border: none;
            padding: 12px 25px;
            border-radius: var(--border-radius);
            cursor: pointer;
            font-size: 0.95rem;
            font-weight: 500;
            letter-spacing: 0.5px;
            transition: var(--transition);
            display: inline-flex;
            align-items: center;
            justify-content: center;
            min-width: 160px;
            text-transform: uppercase;
        }
        
        button i {
            margin-right: 8px;
        }
        
        button:hover {
            transform: translateY(-2px);
            box-shadow: 0 6px 15px rgba(39, 174, 96, 0.3);
        }
        
        button:active {
            transform: translateY(0);
        }
        
        .alert {
            padding: 15px 20px;
            border-radius: var(--border-radius);
            margin-bottom: 25px;
            text-align: center;
            font-weight: 500;
            animation: slideDown 0.5s ease;
            box-shadow: 0 2px 8px rgba(0,0,0,0.1);
            width: 100%;
            max-width: 700px;
            margin-left: auto;
            margin-right: auto;
        }
        
        @keyframes slideDown {
            from {
                opacity: 0;
                transform: translateY(-20px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }
        
        .alert-danger {
            background-color: #fff2f2;
            color: #e74c3c;
            border-left: 4px solid #e74c3c;
        }
        
        .alert-success {
            background-color: #f0fff4;
            color: var(--secondary-dark);
            border-left: 4px solid var(--secondary-color);
        }
        
        .feature-box {
            margin-top: 40px;
            padding: 25px;
            background-color: #f8f9fa;
            border-radius: var(--border-radius);
            border-left: 5px solid var(--primary-color);
            box-shadow: 0 2px 10px rgba(0,0,0,0.05);
        }
        
        .feature-box h3 {
            margin-top: 0;
            color: var(--primary-color);
            font-size: 1.3rem;
            margin-bottom: 12px;
            display: flex;
            align-items: center;
        }
        
        .feature-box h3 i {
            margin-right: 8px;
        }
        
        .feature-box p {
            margin-bottom: 8px;
            font-size: 0.95rem;
            line-height: 1.6;
        }
        
        footer {
            margin-top: auto;
            text-align: center;
            padding: 20px;
            background-color: var(--white);
            color: var(--dark-gray);
            font-size: 0.9rem;
            box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
        }
        
        #fileNameDisplay {
            margin-top: 8px;
            font-style: italic;
            color: var(--primary-color);
            font-weight: 500;
            display: flex;
            align-items: center;
            font-size: 0.9rem;
        }
        
        #fileNameDisplay i {
            margin-right: 5px;
        }
        
        @media (max-width: 768px) {
            .container {
                padding: 25px;
                width: 95%;
                margin: 20px auto;
            }
            
            h1 {
                font-size: 1.6rem;
            }
            
            button {
                width: 100%;
                padding: 12px 20px;
            }
            
            .feature-box h3 {
                font-size: 1.2rem;
            }
        }
        
        /* 加载动画 */
        .loader {
            display: none;
            border: 4px solid var(--light-gray);
            border-top: 4px solid var(--primary-color);
            border-radius: 50%;
            width: 30px;
            height: 30px;
            animation: spin 1s linear infinite;
            margin: 20px auto;
        }
        
        @keyframes spin {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>文档处理工具</h1>
        
        <!-- 导航菜单 -->
        <div class="nav-menu">
            <a href="/" class="active"><i class="fas fa-file-pdf"></i>PDF处理</a>
            <a href="/word" id="wordTab"><i class="fas fa-file-word"></i>Word处理</a>
        </div>
        
        <div th:if="${message}" class="alert" th:classappend="${message.contains('成功') ? 'alert-success' : 'alert-danger'}" th:text="${message}"></div>
        
        <div class="feature-description">
            <h2>PDF处理功能</h2>
            <p>移除PDF中的彩色内容，只保留黑色内容。适用于去除彩色标记、手写注释等。</p>
        </div>
        
        <form action="/upload" method="post" enctype="multipart/form-data" class="upload-form">
            <div class="file-input-container">
                <input type="file" id="file" name="file" accept=".pdf" required />
                <label for="file" class="file-input-label">
                    <i class="fas fa-file-upload"></i>
                    <span id="file-name">选择PDF文件或拖放到这里</span>
                </label>
            </div>
            <button type="submit">
                <i class="fas fa-cog"></i>
                处理文件
            </button>
        </form>
        
        <div class="information-section">
            <h3><i class="fas fa-info-circle"></i> 使用说明</h3>
            <ul>
                <li>上传PDF文件（最大100MB）</li>
                <li>系统会自动移除所有彩色内容</li>
                <li>仅保留黑色文字和内容</li>
                <li>处理后可在线预览和下载</li>
            </ul>
        </div>
    </div>
    
    <script>
        document.addEventListener('DOMContentLoaded', function() {
            // 文件上传交互
            const fileInput = document.getElementById('file');
            const fileNameSpan = document.getElementById('file-name');
            
            fileInput.addEventListener('change', function() {
                if (this.files && this.files[0]) {
                    fileNameSpan.textContent = this.files[0].name;
                    
                    const fileSize = this.files[0].size / 1024 / 1024; // Convert to MB
                    if (fileSize > 100) {
                        alert('文件大小超过100MB限制，请选择更小的文件。');
                        this.value = '';
                        fileNameSpan.textContent = '选择PDF文件或拖放到这里';
                    }
                } else {
                    fileNameSpan.textContent = '选择PDF文件或拖放到这里';
                }
            });
            
            // 拖放功能
            const dropZone = document.querySelector('.file-input-label');
            
            ['dragover', 'dragenter'].forEach(eventName => {
                dropZone.addEventListener(eventName, function(e) {
                    e.preventDefault();
                    dropZone.classList.add('highlight');
                }, false);
            });
            
            ['dragleave', 'dragend', 'drop'].forEach(eventName => {
                dropZone.addEventListener(eventName, function(e) {
                    e.preventDefault();
                    dropZone.classList.remove('highlight');
                }, false);
            });
            
            dropZone.addEventListener('drop', function(e) {
                fileInput.files = e.dataTransfer.files;
                
                if (fileInput.files && fileInput.files[0]) {
                    fileNameSpan.textContent = fileInput.files[0].name;
                    
                    const fileSize = fileInput.files[0].size / 1024 / 1024; // Convert to MB
                    if (fileSize > 100) {
                        alert('文件大小超过100MB限制，请选择更小的文件。');
                        fileInput.value = '';
                        fileNameSpan.textContent = '选择PDF文件或拖放到这里';
                    }
                }
            }, false);
            
            // 页签快速切换优化
            const wordTab = document.getElementById('wordTab');
            if (wordTab) {
                wordTab.addEventListener('mouseenter', function() {
                    const link = document.createElement('link');
                    link.rel = 'prefetch';
                    link.href = '/word';
                    document.head.appendChild(link);
                });
                
                wordTab.addEventListener('click', function(e) {
                    e.preventDefault();
                    wordTab.classList.add('active');
                    document.body.style.opacity = '0.8';
                    setTimeout(function() {
                        window.location.href = wordTab.href;
                    }, 10);
                });
            }
        });
    </script>
</body>
</html> 